#include "Node.h"

int Node::s_id_indexer = 0;
set<int> Node::s_id_set;

Node::Node() {
	parent_ = NULL;
	id_ = Node::getNextId();
}

Node::Node(Node& parent) : Node() {
	parent_ = &parent;
	type_ = parent.type_;
	name_ = parent.name_;
}

Node::~Node() {
	Node::s_id_set.erase(id_);
}

void Node::createNode(string name) {
	name_ = name;
}

int Node::getNextId() {
	int ret = s_id_indexer;
	s_id_set.insert(ret);
	
	do {
		s_id_indexer++;
		if (s_id_indexer < 0)
			s_id_indexer = 0;
	} while (s_id_set.find(ret) == s_id_set.end());

	return ret;
}